<?php
/*
buildDB.php
method: POST
content-type: application/x-www-form-urlencoded
author: Sheila Tabuena 
created: JUN-3-2009
   This file contains code that will build the database tables for the Palo Alto 
   Bicycle Club website. This is a *destructive* operation, it will wipe any
   versions of the tables that already exist. Will build the tables using database
   and account information contained in dbconnector.php
   Builds table(s):
      notices (posted, text);
*/
function doSQL($sql)
{
  $result=mysql_query($sql);
  if (!$result)
  {
     echo '<error>Could not execute sql: <font color="red">'.mysql_error().'</font></error>';//DEBUG
     return false;
  }
  else
    return true;
}
//Include dbconnector.php
require('dbconnector.php');
//Open the database.
$db=opendb();
$sql = "DROP TABLE IF EXISTS calendar";
$result=doSQL($sql);
$sql = "CREATE TABLE calendar ( eventid int(3) auto increment, title varchar2(256),location varchar2(256), speed varchar2(1), hills tinyint(1), miles int(3), date datetime, description blob )";
$result=doSQL($sql);
$sql = 'INSERT INTO calendar (title,location,speed,hills,miles,date,description) VALUES ("Amazing Ride","Palo Alto, CA","A","2","3","2009-06-21 11:30:00","This is the first ride organized by the PABC. Have a great time!")';
$result=doSQL($sql);
?>